<%-- 
    Document   : index
    Created on : Oct 16, 2013, 3:21:44 PM
    Author     : tino
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <%@page import="java.sql.*" %>
        <title>the login page</title>
        <link rel="stylesheet" type="text/css" href="for_login.css">
        <script src="jquery-1.10.2.js"></script>
        <script src="login_bottom.js"></script>
    </head>
    <body>
        <form action="" method="post" name="from">
            <p><input type="text" name="name" placeholder="name"></p>
            <p><input type="password" name="pswd" placeholder="password"></p>
            <input id="button1" type="submit" value="submit" name="submit" >
            <input id="button1" type="reset" value="reset" name="reset">
        </form>
        <%
            Connection con;
            Statement sql;
            ResultSet rs;
            String str1,str2;
            boolean flag=false;
            try {
                Class.forName("com.mysql.jdbc.Driver");
            }
            catch(Exception e){
                out.print(e);
            }
            try{
            String uri = "jdbc:mysql://localhost/someusers";
            con=DriverManager.getConnection(uri,"tino","123456");
            sql=con.createStatement();
            rs=sql.executeQuery("SELECT name,password from users");
            String textContent1=request.getParameter("name");
            String textContent2=request.getParameter("pswd");
            while(rs.next()){
               // if((textContent1==rs.getString(1))&&(textContent2==rs.getString(2))){
                    str1=rs.getString(1);
                    str2=rs.getString(2);
                    if(str1.equals(textContent1)&&str2.equals(textContent2)){
                        out.print("hello<br><br>");
                        flag=true;
                    }
                    
               //}
               // else{
                 //   out.print("this is error inputs"+"<br>");
               // }
            }
            con.close();
            }
            catch(SQLException e1){
                out.print(e1);
            }
            if(flag==true){
                %>
                <jsp:forward page="try.jsp" />
                <%
            }
        %>
    </body>
</html>
